﻿using System;
using System.Data;
using System.Collections.Generic;
using ElingOA6_DSJCJ.Model;
namespace ElingOA6_DSJCJ.BLL
{
	/// <summary>
	/// 组织机构
	/// </summary>
	public partial class Entity
	{
        private readonly ElingOA6_DSJCJ.DAL.Entity dal = new ElingOA6_DSJCJ.DAL.Entity();
		public Entity()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string FEntityNo)
		{
			return dal.Exists(FEntityNo);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ElingOA6_DSJCJ.Model.Entity model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ElingOA6_DSJCJ.Model.Entity model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string FEntityNo)
		{
			
			return dal.Delete(FEntityNo);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string FEntityNolist )
		{
			return dal.DeleteList(FEntityNolist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ElingOA6_DSJCJ.Model.Entity GetModel(string FEntityNo)
		{
			
			return dal.GetModel(FEntityNo);
		}

		

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ElingOA6_DSJCJ.Model.Entity> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ElingOA6_DSJCJ.Model.Entity> DataTableToList(DataTable dt)
		{
			List<ElingOA6_DSJCJ.Model.Entity> modelList = new List<ElingOA6_DSJCJ.Model.Entity>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ElingOA6_DSJCJ.Model.Entity model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ElingOA6_DSJCJ.Model.Entity();
					if(dt.Rows[n]["FEntityNo"]!=null && dt.Rows[n]["FEntityNo"].ToString()!="")
					{
					model.FEntityNo=dt.Rows[n]["FEntityNo"].ToString();
					}
					if(dt.Rows[n]["FEntityName"]!=null && dt.Rows[n]["FEntityName"].ToString()!="")
					{
					model.FEntityName=dt.Rows[n]["FEntityName"].ToString();
					}
					if(dt.Rows[n]["FLeader"]!=null && dt.Rows[n]["FLeader"].ToString()!="")
					{
					model.FLeader=dt.Rows[n]["FLeader"].ToString();
					}
					if(dt.Rows[n]["FShortName"]!=null && dt.Rows[n]["FShortName"].ToString()!="")
					{
					model.FShortName=dt.Rows[n]["FShortName"].ToString();
					}
					if(dt.Rows[n]["FAccessDate"]!=null && dt.Rows[n]["FAccessDate"].ToString()!="")
					{
						model.FAccessDate=DateTime.Parse(dt.Rows[n]["FAccessDate"].ToString());
					}
					if(dt.Rows[n]["FLastLoginIPAddr"]!=null && dt.Rows[n]["FLastLoginIPAddr"].ToString()!="")
					{
					model.FLastLoginIPAddr=dt.Rows[n]["FLastLoginIPAddr"].ToString();
					}
					if(dt.Rows[n]["FLogID"]!=null && dt.Rows[n]["FLogID"].ToString()!="")
					{
					model.FLogID=dt.Rows[n]["FLogID"].ToString();
					}
					if(dt.Rows[n]["fuseTimes"]!=null && dt.Rows[n]["fuseTimes"].ToString()!="")
					{
						model.fuseTimes=int.Parse(dt.Rows[n]["fuseTimes"].ToString());
					}
					if(dt.Rows[n]["FPublishRoot"]!=null && dt.Rows[n]["FPublishRoot"].ToString()!="")
					{
					model.FPublishRoot=dt.Rows[n]["FPublishRoot"].ToString();
					}
					if(dt.Rows[n]["FWaterMarkContent"]!=null && dt.Rows[n]["FWaterMarkContent"].ToString()!="")
					{
						model.FWaterMarkContent=(byte[])dt.Rows[n]["FWaterMarkContent"];
					}
					if(dt.Rows[n]["FWaterMarkSvrFileName"]!=null && dt.Rows[n]["FWaterMarkSvrFileName"].ToString()!="")
					{
					model.FWaterMarkSvrFileName=dt.Rows[n]["FWaterMarkSvrFileName"].ToString();
					}
					if(dt.Rows[n]["FWaterMarkExt"]!=null && dt.Rows[n]["FWaterMarkExt"].ToString()!="")
					{
					model.FWaterMarkExt=dt.Rows[n]["FWaterMarkExt"].ToString();
					}
					if(dt.Rows[n]["FWaterMarkOldFileName"]!=null && dt.Rows[n]["FWaterMarkOldFileName"].ToString()!="")
					{
					model.FWaterMarkOldFileName=dt.Rows[n]["FWaterMarkOldFileName"].ToString();
					}
					if(dt.Rows[n]["FWebBeiAnNo"]!=null && dt.Rows[n]["FWebBeiAnNo"].ToString()!="")
					{
					model.FWebBeiAnNo=dt.Rows[n]["FWebBeiAnNo"].ToString();
					}
					if(dt.Rows[n]["FCopyRight"]!=null && dt.Rows[n]["FCopyRight"].ToString()!="")
					{
					model.FCopyRight=dt.Rows[n]["FCopyRight"].ToString();
					}
					if(dt.Rows[n]["FTxtWaterMark"]!=null && dt.Rows[n]["FTxtWaterMark"].ToString()!="")
					{
					model.FTxtWaterMark=dt.Rows[n]["FTxtWaterMark"].ToString();
					}
					if(dt.Rows[n]["FSmtpHost"]!=null && dt.Rows[n]["FSmtpHost"].ToString()!="")
					{
					model.FSmtpHost=dt.Rows[n]["FSmtpHost"].ToString();
					}
					if(dt.Rows[n]["FSmtpAccount"]!=null && dt.Rows[n]["FSmtpAccount"].ToString()!="")
					{
					model.FSmtpAccount=dt.Rows[n]["FSmtpAccount"].ToString();
					}
					if(dt.Rows[n]["FSmtpPassword"]!=null && dt.Rows[n]["FSmtpPassword"].ToString()!="")
					{
					model.FSmtpPassword=dt.Rows[n]["FSmtpPassword"].ToString();
					}
					if(dt.Rows[n]["FWaterMarkCls"]!=null && dt.Rows[n]["FWaterMarkCls"].ToString()!="")
					{
					model.FWaterMarkCls=dt.Rows[n]["FWaterMarkCls"].ToString();
					}
					if(dt.Rows[n]["FSmtpPort"]!=null && dt.Rows[n]["FSmtpPort"].ToString()!="")
					{
						model.FSmtpPort=int.Parse(dt.Rows[n]["FSmtpPort"].ToString());
					}
					if(dt.Rows[n]["FIsSsl"]!=null && dt.Rows[n]["FIsSsl"].ToString()!="")
					{
						model.FIsSsl=decimal.Parse(dt.Rows[n]["FIsSsl"].ToString());
					}
					if(dt.Rows[n]["FFlowLockTime"]!=null && dt.Rows[n]["FFlowLockTime"].ToString()!="")
					{
						model.FFlowLockTime=int.Parse(dt.Rows[n]["FFlowLockTime"].ToString());
					}
					if(dt.Rows[n]["FIsIPControl"]!=null && dt.Rows[n]["FIsIPControl"].ToString()!="")
					{
					model.FIsIPControl=dt.Rows[n]["FIsIPControl"].ToString();
					}
					if(dt.Rows[n]["FNTKOCaption"]!=null && dt.Rows[n]["FNTKOCaption"].ToString()!="")
					{
					model.FNTKOCaption=dt.Rows[n]["FNTKOCaption"].ToString();
					}
					if(dt.Rows[n]["FNTKOKey"]!=null && dt.Rows[n]["FNTKOKey"].ToString()!="")
					{
					model.FNTKOKey=dt.Rows[n]["FNTKOKey"].ToString();
					}
					if(dt.Rows[n]["FSysCopyRight"]!=null && dt.Rows[n]["FSysCopyRight"].ToString()!="")
					{
					model.FSysCopyRight=dt.Rows[n]["FSysCopyRight"].ToString();
					}
					if(dt.Rows[n]["FSysTitle"]!=null && dt.Rows[n]["FSysTitle"].ToString()!="")
					{
					model.FSysTitle=dt.Rows[n]["FSysTitle"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method


        #region 增加的方法

        /// <summary>
        /// 获取系统标题
        /// <creator>rend</creator>
        /// <date>2013-2-5</date>
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public string GetSysTitle(string entityNo) {
            return dal.GetSysTitle(entityNo);
        }



        /// <summary>
        /// 获取权属说明
        /// <creator>rend</creator>
        /// <date>2013-2-5</date>
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public string GetCopyRight(string entityNo)
        {
            return dal.GetCopyRight(entityNo);
        }
        
        /// <summary>
        ///  更新有关最近登录等相关的信息
        /// <creator>rend</creator>
        /// <date>2013-2-6</date>
        /// </summary>
        /// <param name="model"></param>
        public void UpdateByEntityNo(Model.Entity model)
        {
            dal.UpdateByEntityNo(model);
        }



        /// <summary>
        /// 判断该用户某个时间段是否登录过,用于表t_EmpSignTime
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="emplNo"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public bool ExistsSignTime(string emplNo, string beginTime, string endTime)
        {
            return dal.ExistsSignTime(emplNo, beginTime, endTime);
        }


        /// <summary>
        ///  增加一条签到,用于表t_EmpSignTime
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="empNO"></param>
        /// <param name="time"></param>
        public void AddSignTime(string empNO, DateTime time)
        {
            dal.AddSignTime(empNO, time);
        }


        /// <summary>
        /// 获取绩效考核最大年度
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="FEntityNo"></param>
        /// <returns></returns>
        public string GetCxcsEvlaClassMaxYear(string FEntityNo)
        {
            return dal.GetCxcsEvlaClassMaxYear(FEntityNo);
        }



        
        /// <summary>
        /// 获取政府采购当前年度
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="strEntityNo"></param>
        /// <returns></returns>
        public int GetGovYear(string strEntityNo)
        {
            return dal.GetGovYear(strEntityNo);
        }


        #endregion


    }
}